package cn.kmust.booth.portal.controller;


import cn.kmust.booth.portal.model.TypeCost;
import cn.kmust.booth.portal.service.ITypeCostService;
import cn.kmust.booth.portal.vo.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ZhYoG
 * @since 2020-08-05
 */
@RestController
@RequestMapping("/api/v1/typeCosts")
@Slf4j
public class TypeCostController {
    @Autowired(required = false)
    private ITypeCostService typeCostService;

    //http://localhost:8080/api/v1/typeCosts/add?type=111&message=222&userId=1
    @RequestMapping("/add")
    public R<Void> add(TypeCost typeCost, Integer userId){
        typeCostService.add(typeCost,userId);
        return R.ok();
    }

    //http://localhost:8080/api/v1/typeCosts/delete?id=1&userId=1
    @RequestMapping("/delete")
    public R<Void> delete(Integer id,Integer userId){
        typeCostService.delete(id,userId);
        return R.ok();
    }

    //http://localhost:8080/api/v1/typeCosts/update?type=111&message=222&id=2&userId=1
    @RequestMapping("/update")
    public R<Void> update(TypeCost typeCost, Integer id,Integer userId){
        typeCostService.update(typeCost,id,userId);
        return R.ok();
    }
}
